﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 判断闰年
{
    class Program
    {
       //用户输入年份,再输入月份,输出该月的天数.
        static void Main(string[] args)
        {
            Console.Write("请输入年份:");
            int year = int.Parse(Console.ReadLine());
            Console.Write("请输入月份:");
            int month = int.Parse(Console.ReadLine());
            int day = 0;
            
            switch (month)
            {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    day = 31;
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    day = 30;
                    break;
                case 2:
                    if (DateTime.IsLeapYear(year))
                    {
                        day = 29;
                    }
                    else
                    {
                        day = 28;
                    }
                    break;
                default:
                    Console.WriteLine("请输入1-12月份!");
                    break;
            }
            Console.Write("{0}年{1}月有:{2}天",year,month,day);
        }
    }
}
